# Copyright 2007 Joseph Lisee
#
# Author: Joseph Lisee
# License: Public Domain

"""
This module contains a custom GCC-XML tool for SCons
"""

import SCons.Builder
import SCons.Tool
import os

ILCGBuilder = SCons.Builder.Builder(action = "$ILCG $ILCG_FLAGS $SOURCE $TARGETS out.log",
                              suffix='cpp',
                              src_suffic = ['xml'])
def generate(env):
    if 'ILCG_PATH' in env:
        ilcg_path = env['ILCG_PATH']
    else:
        ilcg_path = env.WhereIs('ilcg')
    if ilcg_path is None:
        print 'Could not find ilgc, please make sure it is on your PATH'
        env.Exit(1)
    if env['PLATFORM'] == 'win32': ilcg_path = ilcg_path.replace('/','\\')
    env['ILCG'] = ilcg_path

    env['ILCG_FLAGS'] = ''
    env.Append(BUILDERS = {'ILCG' : ILCGBuilder })

def exists(env):
    return env.Detect('ilcg')
